<?php $this->_extends('_layouts/bootstrap_layout'); ?>
<?php $this->_block('contents'); ?>
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url');?>js/validator.js"></script>
<script type="text/javascript">
$(function(){
	$("form").submit(function(){  
		var flag = Validator.Validate(this,3);
		if (flag)
		{
			 $("#submit").attr("disabled","disabled");  
		}
		return flag;
	}); 
    var _top = $("#thead").offset().top;
    $(window).scroll(function(){
        if ($(this).scrollTop() > _top && $("tbody").children("tr").length > 3)
		{
            $("#thead").css({ "top": 0, "position": "fixed", "background-color": "white" });
          	$("table").find("#thead th").each(function(i){
				$(this).css("width", $("table").find("td:eq(" + i + ")").width());
			});
        }
        else
		{
			$("#thead").css({ "top": _top, "position": "static" });
		}
    });
});
</script>
<style type="text/css">
.red{
	color:red;	
	}
.span2{
	width:260px;
	}
</style>
<div class="container">
<form method="get" action="">
<?include(Q::ini('custom_system/elements_dir') . 'searchform_element.php');?>
  <fieldset>
    <legend><?=$title?></legend>
    <?if (isset($result)):?>
	<table class="table table-bordered">
	<thead id="thead" class="table-bordered">
	<tr>
		<th id="th1">国家</th>
		<th id="th2">国家二字码</th>
		<th id="th3">邮寄方式</th>
		<th id="th4">价格(CNY)</th>
		<th id="th5">状态</th>
	</tr>
	</thead>
	<tbody>
	<?foreach ($result as $k => $r):?>
		<tr class="<?if ($r['ack'] == SUCCESS){echo $r['ack'];}else{echo 'error';}?>">
		<td width="180"><?=$r['cn_name']?></td>
		<td width="100"><?=$r['country_code']?></td>
		<td width="240"><?=Shipping_Method::getShippingMethodByCode($r['code'], 'name')?></td>
		<td width="100"><?=$r['postage_currency_symbol'] . $r['postage']?></td>
		<td width="150"><?=empty($r['message'])?'查询成功':$r['message']?></td>
	</tr>
	<?endforeach;?>
	</tbody>
	</table>
	<?endif;?>
    <label>目的国家</label>
    <div>
	    <select class="span2" name="country[]" size="12" multiple="multiple" equire="false" dataType="Require" msg="请选择国家">
		<?foreach ($country as $c):?>
		<option value="<?=$c['code']?>" <?if (isset($_GET['country']) && in_array($c['code'], $_GET['country']))echo "selected='selected'"?>><?=$c['code'] .' '. $c['cn_name']?></option>
		<?endforeach;?>
		</select>
		<span class="red">*</span>
	</div>
	<label>邮寄方式</label>
	<div>
	    <select class="span2" name="shipping_method[]" size="12" multiple="multiple" dataType="Require" msg="请选择邮寄方式">
		<?foreach ($shipping_method as $sm):?>
		<option value="<?=$sm['code']?>" <?if (isset($_GET['shipping_method']) && in_array($sm['code'], $_GET['shipping_method']))echo "selected='selected'"?>><?=$sm['name']?></option>
		<?endforeach;?>
		</select>
		<span class="red">*</span>
	</div>
    <div>
	    <span class="add-on">重量</span>
	    <input class="input-mini" type="text" name="weight" value="<?=isset($_GET['weight']) ? $_GET['weight'] : ''?>" dataType="Require" msg="请填写重量" />
	    <span class="add-on">g</span>
	    <span class="red">*</span>
    </div>
    <br/>
    <button type="submit" class="btn">马上查询</button>
  </fieldset>
</form>
</div>
<?php $this->_endblock();?>